package com.leaf.u_spring.chapter04;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;

/**
 * 演出效果 
 * 
 * @Aspect注解表明Audience类不仅仅是个POJO，还是一个切面
 * Audience类中的方法都使用注解来定义切面的具体行为
 */
@Aspect
public class Audience {

	/**
	 * 表演之前
	 */
	@Before("execution(** com.leaf.u_spring.chapter04.Performance.perform(..))")
	public void silenceCellPhones(){
		System.out.println("silence Cell Phones");
	}
	
	/**
	 * 表演之前
	 */
	@Before("execution(** com.leaf.u_spring.chapter04.Performance.perform(..))")
	public void takeSeates(){
		System.out.println("taking seates");
	}
	
	
	/**
	 * 表演之后
	 */
	@AfterReturning("execution(** com.leaf.u_spring.chapter04.Performance.perform(..))")
	public void applause(){
		System.out.println("CLAP CLAP CLAP!!!");
	}
	
	/**
	 * 表演失败之后
	 */
	@AfterThrowing("execution(** com.leaf.u_spring.chapter04.Performance.perform(..))")
	public void demandRefund(){
		System.out.println("Demanding a refund");
	}
	
}
